TO_CHAR (datetime)

Purpose

This function converts a date, timestamp or interval into a string.

Syntax

to_char (datetime)::=

Usage Notes

  • The standard format is used if no format is specified, this is defined in session parameter ALTER SESSION or ALTER SESSION.
  • For information, refer to the Date/time format models.
  • By the optional third parameter you can specify the language setting for the format (for example, NLS_DATE_LANGUAGE).
  • Supported languages are German (DEU, DEUTSCH or GERMAN) and English (ENG or ENGLISH).
  • For data type TIMESTAMP WITH LOCAL TIME ZONE this function is calculated within the session time zone.
  • Results for variable-length format masks such as MONTH and DATE will be padded with spaces to their longest possible value.

Example

SELECT TO_CHAR(DATE '1999-12-31') TO_CHAR;

SELECT TO_CHAR(TIMESTAMP '1999-12-31 23:59:00',
               'HH24:MI:SS DD-MM-YYYY') TO_CHAR;

SELECT TO_CHAR(DATE '2013-12-16',
               'DD. MON YYYY',
               'NLS_DATE_LANGUAGE=DEU') TO_CHAR;